from selenium import webdriver
import time
import os


class Case:
    def __init__(self):
        self.driver = webdriver.Chrome()
        url = os.path.join(os.path.abspath('html'), 'popup.html')
        self.driver.get(url)
        self.button_list = self.driver.find_elements_by_tag_name('button')

    def alert(self):
        self.button_list[0].click()
        alert = self.driver.switch_to.alert
        time.sleep(2)
        alert.accept()


if __name__ == '__main__':
    case = Case()
    case.alert()
